define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'eduadmin/enroll/index',
                    add_url: 'eduadmin/enroll/add',
                    edit_url: 'eduadmin/enroll/edit',
                    del_url: 'eduadmin/enroll/del',
                    multi_url: 'eduadmin/enroll/multi',
                    table: 'enroll',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'studentname', title: __('Studentname')},
                        {field: 'courseid', title: __('Courseid')},
                        {field: 'description', title: __('Description')},
                        {field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'classcount', title: __('classcount')},
                        {field: 'classprice', title: __('Classprice'), operate:'BETWEEN'},
                        {field: 'totalamount', title: __('Totalamount'), operate:'BETWEEN'},
                        {field: 'paymount', title: __('Paymount'), operate:'BETWEEN'},
                        {field: 'paystatus', title: __('Paystatus'), visible:false, searchList: {"\u5df2\u7f34\u8d39":__('\u5df2\u7f34\u8d39'),"\u672a\u7f34\u8d39":__('\u672a\u7f34\u8d39')}},
                        {field: 'paystatus_text', title: __('Paystatus'), operate:false},
                        {field: 'studenttell', title: __('Studenttell')},
                        {field: 'studentaddress', title: __('Studentaddress')},
                        {field: 'studentschool', title: __('Studentschool')},
                        {field: 'parenttell', title: __('Parenttell')},
                        {field: 'parentcompany', title: __('Parentcompany')},
                        {field: 'followteacher', title: __('Followteacher')},
                        {field: 'branch', title: __('Branch')},
                        {field: 'status', title: __('Status'), visible:false, searchList: {"\u5df2\u8f6c\u5b66":__('\u5df2\u8f6c\u5b66'),"\u5df2\u5173\u95ed":__('\u5df2\u5173\u95ed'),"\u5df2\u9000\u5b66":__('\u5df2\u9000\u5b66'),"\u672a\u5206\u73ed":__('\u672a\u5206\u73ed'),"\u5df2\u5206\u73ed":__('\u5df2\u5206\u73ed')}},
                        {field: 'status_text', title: __('Status'), operate:false},
                        {field: 'weigh', title: __('Weigh')},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'createby', title: __('Createby')},
                        {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'updateby', title: __('Updateby')},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});